package com.bootdo.app;


import com.bootdo.common.domain.DictDO;
import com.bootdo.common.service.DictService;
import com.bootdo.common.utils.AppR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@Controller
@RequestMapping("/api/dict/common")
public class AppCommonController {



    @Autowired
    private DictService dictService;

    /**
     * 根据类型查询数据字典
     * @param type
     * @return
     */
    @GetMapping("/type")
    @ResponseBody
    public AppR getDictByType(@RequestParam String type) {
        return AppR.ok(dictService.listByType(type));
    }


    @GetMapping("/value")
    @ResponseBody
    public DictDO getDictByTypeValue(@RequestParam String value) {
        Map<String,Object> map = new HashMap<>();
        map.put("value",value);
        List<DictDO> list=dictService.list(map);

        return list.get(0);
    }











}
